<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<table class="display" id="example">
    <thead>
    <tr>
        <th>选择</th>
        <th><strong>考核项目</strong></th>
        <th>占比</th>
        <s:if test="#request.examQualStandardSets!=null and #request.examQualStandardSets.size() > 0">
        <s:iterator value="#request.examQualStandardSets" var="qss" status="sta">
        <th>${qss.name}(${qss.scoreStart}-${qss.scoreEnd})</th>
        </s:iterator>
        </s:if>
        <th style="min-width:60px">操作</th>
    </tr>
    </thead>
    <tbody>
    <s:if test="#request.examQualStandardSets==null or #request.examQualStandardSets.size() <= 0">
        <tr> <td>没有考核标准数据</td> </tr>
    </s:if>
    <s:else>
        <s:if test="#request.examQualItemSets==null or #request.examQualItemSets.size() <= 0">
            <tr> <td>暂无数据</td> </tr>
        </s:if>
        <s:else>
            <s:iterator value="#request.examQualItemSets" var="qis" status="sta">
            <s:if test="#sta.even"> <tr class="gradeA"> </s:if> <s:else> <tr class="gradeC"> </s:else>
                <td><input type="checkbox" name="check_item_o${organizationId}" value="${qis.id}"/></td>
                <td>${qis.title}</td>
                <td>${qis.percentage}%</td>
                <s:if test="#request.examQualStandardSets.size() == 1">
                <td>${qis.desc1}</td>
                </s:if>
                <s:elseif test="#request.examQualStandardSets.size() == 2">
                <td>${qis.desc1}</td><td>${qis.desc2}</td>
                </s:elseif>
                <s:elseif test="#request.examQualStandardSets.size() == 3">
                <td>${qis.desc1}</td><td>${qis.desc2}</td><td>${qis.desc3}</td>
                </s:elseif>
                <s:elseif test="#request.examQualStandardSets.size() == 4">
                <td>${qis.desc1}</td><td>${qis.desc2}</td><td>${qis.desc3}</td><td>${qis.desc4}</td>
                </s:elseif>
                <s:elseif test="#request.examQualStandardSets.size() == 5">
                <td>${qis.desc1}</td><td>${qis.desc2}</td><td>${qis.desc3}</td><td>${qis.desc4}</td><td>${qis.desc5}</td>
                </s:elseif>
                <s:elseif test="#request.examQualStandardSets.size() == 6">
                <td>${qis.desc1}</td><td>${qis.desc2}</td><td>${qis.desc3}</td><td>${qis.desc4}</td><td>${qis.desc5}</td><td>${qis.desc6}</td>
                </s:elseif>
                <s:elseif test="#request.examQualStandardSets.size() == 7">
                <td>${qis.desc1}</td><td>${qis.desc2}</td><td>${qis.desc3}</td><td>${qis.desc4}</td><td>${qis.desc5}</td><td>${qis.desc6}</td><td>${qis.desc7}</td>
                </s:elseif>
                <s:elseif test="#request.examQualStandardSets.size() == 8">
                <td>${qis.desc1}</td><td>${qis.desc2}</td><td>${qis.desc3}</td><td>${qis.desc4}</td><td>${qis.desc5}</td><td>${qis.desc6}</td><td>${qis.desc7}</td><td>${qis.desc8}</td>
                </s:elseif>
                <s:elseif test="#request.examQualStandardSets.size() == 9">
                <td>${qis.desc1}</td><td>${qis.desc2}</td><td>${qis.desc3}</td><td>${qis.desc4}</td><td>${qis.desc5}</td><td>${qis.desc6}</td><td>${qis.desc7}</td><td>${qis.desc8}</td><td>${qis.desc9}</td>
                </s:elseif>
                <s:elseif test="#request.examQualStandardSets.size() == 10">
                <td>${qis.desc1}</td><td>${qis.desc2}</td><td>${qis.desc3}</td><td>${qis.desc4}</td><td>${qis.desc5}</td><td>${qis.desc6}</td><td>${qis.desc7}</td><td>${qis.desc8}</td><td>${qis.desc9}</td><td>${qis.desc10}</td>
                </s:elseif>
                <s:else><td></td></s:else>
                <td style="width:50px" ><a class="button" href="#exam/qual_item_add.xhtml?examQualItemSet.id=${qis.id}&organizationId=${organizationId}"><span style="background:url(${ctx}/images/img/page_edit.png)" class="icon">&nbsp;</span>修改</a></td>
            </tr>
            </s:iterator>
        </s:else>
    </s:else>
    </tbody>
</table>

<p><%@ include file="/WEB-INF/pages/common/main_orgtab_pager.jsp"%></p>
<s:set name="exam_standard_set_is_null" value="#request.examQualStandardSets == null or #request.examQualStandardSets.size() == 0" />

<script type="text/javascript">
    $(function(){
        if("${exam_standard_set_is_null}" == "false"){
            $("#qual_item_message_p").hide();
            $("#qual_item_opt_p").show();
        }else if("${exam_standard_set_is_null}" == "true"){
            $("#qual_item_opt_p").hide();
            $("#qual_item_message_p").show();
        }
    });
    function checkAllByOrg(obj){
        checkAll(obj, "check_item_o${organizationId}");
    }
    function addByOrg(){
        $.ajax({
            type:"post",
            url:"/ajax/exam_qual_item_percent.xhtml?organizationId=${organizationId}",
            //data: "name=John&location=Boston",
            dataType:"json",
            success:function (data) {
                if(data >= 100){
                    alert("考核项目已分配完100%")
                    return;
                }else{
                    window.location.href = "#exam/qual_item_add.xhtml?organizationId=${organizationId}&t=<%=new java.util.Date().getTime()%>"
                }
            }
        });
    }
    //删除
    function deleteChecked(){
        var checkIds = new Array();
        $("input[type='checkbox'][name='check_item_o${organizationId}']").each(function(){
            if(this.checked){
                checkIds.push(this.value);
            }
        });
        if(checkIds.length == 0){
            alert("请选择要删除的数据")
            return;
        }
        if(confirm("确定要删除选中的数据吗？")){
            var url = "${ctx}/exam/qual_item_remove.xhtml";
            //refreshListContent(url, {"organizationId":"${organizationId}", "ids":checkIds.join(",")});
            $.ajax(url, {
                type: "POST",
                data:{"organizationId":"${organizationId}", "ids":checkIds.join(",")},
                dataType:"html",
                cache:false,
                success:function(a) {
                    var obj = $("#list_content_${organizationId}");
                    obj.html("");
                    obj.append(a);
                },
                complete:function() {
                }
            });
        }
    }
    $(function(){
        $("#all_item").attr("checked", false);
        $("#all_item").parent("span").removeClass("checked");
    });
</script>